	//---------------------------------------------------------------------
	// Includes
	//---------------------------------------------------------------------		
	#include <Rendering/BatchRender.hpp>
	#include <Rendering/Renderer.hpp>
	
namespace Rendering {
	
	//---------------------------------------------------------------------	
	RenderingQueue::RenderingQueue() {
	}
	//---------------------------------------------------------------------	
	void RenderingQueue::Add(const TShaderEnvironnementPointer& env) {		
		queue[env->GetProgram()->GetRenderingID()].push_back(env);
	}
	//---------------------------------------------------------------------	
	void RenderingQueue::RenderQueue() {
		TShaderEnvironnementPointerMap::iterator it;
		for(it = queue.begin(); it != queue.end(); ++it) {
			int size = it->second.size();
			Renderer::Instance().EnableShader(it->first);
			it->second[0]->GetContext(PUBLIC_CONTEXT)->Enable();
			for(int i=0; i<size; ++i) {
				it->second[i]->GetContext(PRIVATE_CONTEXT)->Enable();
				it->second[i]->GetContext(GEOMETRIC_CONTEXT)->Enable();
				it->second[i]->GetContext(GEOMETRIC_CONTEXT)->Disable();
				it->second[i]->GetContext(PRIVATE_CONTEXT)->Disable();
			}
			it->second[0]->GetContext(PUBLIC_CONTEXT)->Disable();
			Renderer::Instance().DisableShader(it->first);
		}
	}
}
